package leetcode.l0530;

import leetcode.l0526.TreeNode;

/**
 * @author Retain
 * @date 2021/5/30 15:20
 */
public class Easy_翻转二叉树_226 {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }else {
            // 遇到节点就交换左右节点
            TreeNode node = root.left;
            root.left = root.right;
            root.right = node;
            invertTree(root.left);
            invertTree(root.right);
        }
        return root;
    }

}
